export default {
  name: 'punish',
  components: {
    cityCascader: () => import("../../../component/cityCascader/index.vue"),
    exportBtn: () => import("../../../component/exportBtn/index.vue"),
  },
  data() {
    return {
      form: {
        startdate: '',
        enddate: '',
        nickname: "",
        punishtype: "", // 处罚类型
        province: "",
        city: "",
        area: "",
        pagenum: 1,
        pagesize: 10,
        citys: []
      },
      url: "/app/v1/platform/statistic/platformPunishListOut",
      level: '0',
      options: [{
          value: '1',
          label: '异常离职'
        }, {
          value: '2',
          label: '面试爽约'
        }, {
          value: '3',
          label: '复试异常'
        },
        {
          value: '4',
          label: '录取异常'
        },
        {
          value: '5',
          label: '入职异常'
        }
      ],
      tableData: [],
      total: 0,
      totalintegral: 0,
      loading: false,
      
      dialogVisible: false,
      detail: {}
    }
  },
  created() {
    this.getTableData();
  },
  methods: {
    // 选择城市
    handleCityChange(val) {
      this.form.citys = val;
      this.form.province = val[0];
      this.form.city = val[1];
      this.form.area = val[2];
    },
    // 时间比较
    compareDate() {
      let startdate = Date.parse(this.form.startdate);
      let enddate = Date.parse(this.form.enddate);
      if (startdate > enddate) {
        this.$message({
          message: '开始时间不能大于结束时间',
          type: 'error'
        });
        return false;
      } else {
        return true;
      }
    },
    getTableData() {
      if (!this.compareDate()) {
        return
      } else {
        this.loading = true
        this.$axios.$post('/app/v1/platform/summary/platformPunishList', this.form).then(res => {
          this.loading = false;
          if (res.data.message === 'success.') {
            this.tableData = res.data.data.list;
            this.total = +res.data.data.totalnum || 0;
            this.totalintegral = res.data.data.totalintegral || 0;
          }
        })
      }
    },
    // 查询
    query() {
      this.form.pagenum = 1;
      this.getTableData();
    },
    // 重置
    reset() {
      ["startdate", "enddate", "nickname", "type", "province", "city", "area"].forEach(el => {
        this.form[el] = "";
      })
      this.form.citys = [];
    },
    // 分页
    handleCurrentChange(val) {
      this.form.pagenum = val;
      this.getTableData();
    },
    handleSizeChange(val) {
      this.form.pagenum = 1;
      this.form.pagesize = val;
      this.getTableData();
    },
    handleClick(row) {
      this.detail = {...row};
      this.dialogVisible = true;
    }
  }
}